<template>
	<div>
		
	<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
	  <van-list
	    v-model="loading"
	    :finished="finished"
	    :finished-text="finishedText"
	    @load="onLoad"
	    :immediate-check="false"
	  >
	  
	  
	  
	  
	  </van-list>
	</van-pull-refresh> 		
		       
	</div>	
</template>

<script>
import {getFun} from '@/api/publicFun.js'	 
let publicFun=getFun()	
export default {	
	data() {
       return {
       	  loading: false,    // 是否处于数据加载状态 
	      finished: false,   // 是否处于数据最底部的状态 
	      refreshing: false, // 是否处于下拉刷新状态         
          pageNum:1,         // 当前数据的页码数
          pages:0,           // 储存数据的最大页码数
          list:[],            // 储存数据用
          finishedText:''    
       }
	},
	methods: {
	   // 下拉刷新函数	
	   onRefresh() {
		  setTimeout(() => {
	          this.pageNum=1
	          this.list=[]
	          this.getData()	
	          this.finished = false;
	          this.loading=false
			  this.refreshing = false;
		  }, 1000);          
	   },
	   // 上拉加载函数
	   onLoad(){	   	 
		 setTimeout(() => {		 	
	        if (this.refreshing) {
	          this.list = [];
	          this.refreshing = false;
	        }	        
	        this.pageNum++
	        if(this.pageNum>this.pages){this.finished = true;}
	        else{
              this.getData()
	          this.loading = false;	    
	          this.finishedText='我也是有底线的'
	        }
	      }, 1000);   	
	   },		
       // 获取数据
       getData(){
       	    let that=this
		    this.$Axios.postRequest(this.url1,{userId:this.userId,goodsState:'2'},{pageNum:this.pageNum,pageSize:'5'})
		    .then(function(res) {
		    	that.pages=res.page.pages
                that.list=that.list.concat(res.page.records)
		    })       	
       }
	},
	mixins:[publicFun],	
	mounted() {
	    this.userId=this.$router.currentRoute.query.userId;
		// this.getData()
	}
}	
</script>

<style scoped="" lang="scss">

</style>